home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form frmMain
- BackColor = &H00C0C0C0&
- Caption = "Another demo from Steven Gotz"
- ClientHeight = 480
- ClientLeft = 2415
- ClientTop = 2010
- ClientWidth = 4140
- Height = 1170
- Icon = FRMMAIN.FRX:0000
- Left = 2355
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 480
- ScaleWidth = 4140
- Top = 1380
- Width = 4260
- Begin CommandButton Command1
- Caption = "Command1"
- Height = 495
- Index = 0
- Left = 0
- TabIndex = 0
- Top = 0
- Width = 1400
- End
- Begin CommandButton Command1
- Caption = "Command1"
- Height = 495
- Index = 2
- Left = 2775
- TabIndex = 2
- Top = 0
- Width = 1400
- End
- Begin CommandButton Command1
- Caption = "Command1"
- Height = 495
- Index = 1
- Left = 1400
- TabIndex = 1
- Top = 0
- Width = 1400
- End
- Begin Menu mnuFile
- Caption = "&File"
- Begin Menu mnuExit
- Caption = "E&xit"
- End
- End
- Begin Menu mnuEdit
- Caption = "&Edit"
- Begin Menu mnuEditIni
- Caption = "E&dit INI File"
- End
- End
- Begin Menu mnuHelp
- Caption = "&Help"
- Begin Menu mnuHelpFile
- Caption = "&Help"
- End
- Begin Menu mnuAbout
- Caption = "&About"
- End
- End
- 'See .BAS files
- Sub Command1_Click (index As Integer)
- Static hWnds() As Integer
- x% = index 'it is easier to type x% than index
- 'Figure out which line to read - Button1, Button2 etc.
- ButtonIndex$ = "Button" & LTrim(Str$(x% + 1))
- 'Read the INI file for the Application name (i.e. calc.exe) and Window Title
- 'Be careful - I only allowed for one possible window with the same
- 'general title - use the wildcard wisely
- AppName$ = ReadINIFile("Applications", ButtonIndex$, IniName)
- Title$ = ReadINIFile("Title", ButtonIndex$, IniName)
- ' Find window with Window title retrieved from the INI file
- Handle% = FindWindowLike(hWnds(), 0, Title$, "*", Null)
-
- If Handle% = 0 Then 'if App is not running
- x% = Shell(AppName$, 1) 'shell by using Application name
- Else 'if App is running
- 'Get the length of task name identified by hWnds(1)
- Length = GetWindowTextLength(hWnds(1))
- 'Get task name of the task in the master list.
- ListItem$ = Space$(Length + 1) 'make room first
- Length = GetWindowText(hWnds(1), ListItem$, Length + 1)
- AppActivate ListItem$ 'Activate the App.
- SendKeys "%{ }r", True 'To restore App.
- End If
- End Sub
- Sub Form_Load ()
- 'Declare the name of the INI file for use in all INI functions
- 'since it is easier to do it only once
- IniName = "progstrt.ini"
- 'Put the Help menu item on the right
- 'Not recommended by Microsoft but I like it
- mnuHelp.Caption = Chr$(8) + mnuHelp.Caption
- 'Read the captions for the buttons out of the progstrt.ini file
- 'and assign to the caption property - see INIFILES.BAS
- For x% = 0 To 2
- ButtonIndex$ = "Button" & LTrim(Str$(x% + 1))
- command1(x%).Caption = ReadINIFile("Buttons", ButtonIndex$, IniName)
- Next x%
- End Sub
- Sub mnuAbout_Click ()
- 'The Icon will be taken from the application.
- 'This is really quite easy to use.
- 'I use this very program as a starter for almost
- 'all of my apps now. Modify the DisplayAboutBox line
- 'and change the MyInfoLabel label caption and
- 'the label1 caption and you should be in business.
- ' Application ver, year company verbose appname date
- DisplayAboutBox frmMain, "The Start Other Programs Demo", 1.01, "1995", "Steven Gotz", "Another Demo from Steven Gotz", "Apr 14, 1995", 0, True, 0, &HC0C0C0
- End Sub
- Sub mnuEditIni_Click ()
- IniFileBeginStr$ = GetWindowsDir()
- NotepadAndIniFileNameWithPath$ = "Notepad.exe " & IniFileBeginStr$ & IniName
- x% = DOShell(NotepadAndIniFileNameWithPath$, 3)
- For x% = 0 To 2
- ButtonIndex$ = "Button" & LTrim(Str$(x% + 1))
- command1(x%).Caption = ReadINIFile("Buttons", ButtonIndex$, IniName)
- Next x%
- End Sub
- Sub mnuExit_Click ()
- Unload frmMain
- End Sub
- Sub mnuHelpFile_Click ()
- x% = Shell("winhelp.exe demo2.hlp", 3)
- End Sub
-